/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View.reportes;

import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import Principals.Validadores;
/**
 *
 * @author Paola
 */
public class Frm_ReporteClientesyPedidos extends javax.swing.JDesktopPane {

    /**
     * Creates new form Frm_ReporteClientesyPedidos
     */
     private DefaultTableModel mdlBuscarVehiculo;
    
    public Frm_ReporteClientesyPedidos() {
        initComponents();
        mdlBuscarVehiculo = new DefaultTableModel();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        tblEnvios = new javax.swing.JTable();
        pnlBuscarPedido = new javax.swing.JPanel();
        lblIntervaloFec = new javax.swing.JLabel();
        lblDesde = new javax.swing.JLabel();
        lblHasta = new javax.swing.JLabel();
        jdcDesde = new com.toedter.calendar.JDateChooser();
        jdcHasta = new com.toedter.calendar.JDateChooser();
        jButton1 = new javax.swing.JButton();
        txtDNI = new javax.swing.JTextField();
        lblHasta1 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        tblEnvios.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Id_pedido", "Cliente", "Producto", "Fecha Reg.", "Fecha Ent.", "Estado"
            }
        ));
        jScrollPane1.setViewportView(tblEnvios);

        pnlBuscarPedido.setBorder(javax.swing.BorderFactory.createTitledBorder("Parámetros"));

        lblIntervaloFec.setText("Intervalo de Fechas");

        lblDesde.setText("Desde:");

        lblHasta.setText("Hasta:");

        jButton1.setText("Buscar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        txtDNI.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtDNIKeyTyped(evt);
            }
        });

        lblHasta1.setText("DNI:");

        javax.swing.GroupLayout pnlBuscarPedidoLayout = new javax.swing.GroupLayout(pnlBuscarPedido);
        pnlBuscarPedido.setLayout(pnlBuscarPedidoLayout);
        pnlBuscarPedidoLayout.setHorizontalGroup(
            pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblIntervaloFec)
                    .addGroup(pnlBuscarPedidoLayout.createSequentialGroup()
                        .addComponent(lblDesde)
                        .addGap(32, 32, 32)
                        .addComponent(jdcDesde, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(48, 48, 48)
                        .addComponent(lblHasta)
                        .addGap(18, 18, 18)
                        .addComponent(jdcHasta, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lblHasta1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(txtDNI, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addGap(98, 98, 98))
        );
        pnlBuscarPedidoLayout.setVerticalGroup(
            pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBuscarPedidoLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lblIntervaloFec)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jdcDesde, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jdcHasta, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblDesde)
                    .addGroup(pnlBuscarPedidoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton1)
                        .addComponent(txtDNI, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lblHasta)
                    .addComponent(lblHasta1))
                .addContainerGap())
        );

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("Reporte de Cleintes y Pedidos");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnlBuscarPedido, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 279, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1))
                .addContainerGap(61, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pnlBuscarPedido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 236, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
   Date fDesde = jdcDesde.getDate();
        Date fHasta = jdcHasta.getDate();
        mdlBuscarVehiculo.setNumRows(0);
    if(fDesde==null||fHasta==null){
         JOptionPane.showMessageDialog(this, "Ingrese ambas fechas");
     return ;
    }
        
    
if (!fDesde.before(fHasta)){
     JOptionPane.showMessageDialog(this, "Corriga las fechas ingresadas");
     return ;
   
    
}
        boolean encontrado =false;
if (txtDNI.getText().equals("55555555")){
    encontrado=true;
      mdlBuscarVehiculo.setNumRows(0);
        mdlBuscarVehiculo = (DefaultTableModel) tblEnvios.getModel();

            Object[] row = new Object[]{"123","Ruben Castillo","Celular","12/12/12 3:00 pm","12/12/12 5:00 pm","Entregado"};
            mdlBuscarVehiculo.insertRow(0, row);
            
            row = new Object[]{"125","Ruben Castillo","Celular","13/12/12 5:00 pm","13/12/12 6:00 pm","Entregado"};
            mdlBuscarVehiculo.insertRow(0, row);
            
              row = new Object[]{"128","Ruben Castillo","Celular","13/12/12 5:10 pm","13/12/12 6:00 pm","Entregado"};
            mdlBuscarVehiculo.insertRow(0, row);
}


        
if (txtDNI.getText().equals("88888888")){
    encontrado=true;
      mdlBuscarVehiculo.setNumRows(0);
        mdlBuscarVehiculo = (DefaultTableModel) tblEnvios.getModel();

            Object[] row = new Object[]{"1233","Jose Ruiz","Celular","12/12/12 3:00 pm","12/12/12 5:00 pm","Entregado"};
            mdlBuscarVehiculo.insertRow(0, row);
            
            row = new Object[]{"1425","Jose Ruiz","Celular","29/12/12 1:00 pm","","Pendiente"};
            mdlBuscarVehiculo.insertRow(0, row);
}

  if (!encontrado  ){
      mdlBuscarVehiculo.setNumRows(0);
  }


        //limpiar();
     //   JOptionPane.showMessageDialog(this, "Se encontró " + mdlBuscarVehiculo.getRowCount() + " conincidencia(s)");
        }//GEN-LAST:event_jButton1ActionPerformed

    private void txtDNIKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDNIKeyTyped
Validadores v = new Validadores();
v.validaMaxSize(evt, 8, txtDNI.getText());
v.validaSoloNumeros(evt);

    }//GEN-LAST:event_txtDNIKeyTyped

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private com.toedter.calendar.JDateChooser jdcDesde;
    private com.toedter.calendar.JDateChooser jdcHasta;
    private javax.swing.JLabel lblDesde;
    private javax.swing.JLabel lblHasta;
    private javax.swing.JLabel lblHasta1;
    private javax.swing.JLabel lblIntervaloFec;
    private javax.swing.JPanel pnlBuscarPedido;
    private javax.swing.JTable tblEnvios;
    private javax.swing.JTextField txtDNI;
    // End of variables declaration//GEN-END:variables
}
